<template>
   <div>
    <!-- 使用HomeHeader组件 -->
    <home-header :city="city"></home-header>
    <!-- 使用轮播组件 -->
    <home-swiper :swiperList="swiperList"></home-swiper>
    <!-- 图标组件 九宫格 -->
    <home-icons :iconList="iconList"></home-icons>
    <!-- 热销推荐 -->
    <home-recommend :recommendList="recommendList"></home-recommend>
    <!-- 周末游 -->
    <home-weekend :weekendList="weekendList"></home-weekend>
  </div>

</template>

<script>
import HomeHeader from './components/Header'
import HomeSwiper from './components/Swiper'
import HomeIcons from './components/Icons'
import HomeRecommend from './components/Recommend'
import HomeWeekend from './components/Weekend'
import axios from 'axios'
export default {
  name: "Home",
  components:{
    HomeHeader : HomeHeader,
    HomeSwiper : HomeSwiper,
    HomeIcons : HomeIcons,
    HomeRecommend:HomeRecommend,
    HomeWeekend:HomeWeekend
  },
  data () {
    return {
       city:"北京",
       swiperList:[],
       iconList:[],
       recommendList:[],
       weekendList:[]
    }
  },
  methods:{
     getHomeInfo () {
        axios.get('/api/index.json').then(this.getHomeInfosucc);
     },
     getHomeInfosucc (res) {
         console.log(res);
         res = res.data
         if (res.ret && res.data) {
           const data = res.data
           this.swiperList = data.swiperList;
           this.iconList = data.iconList;
           this.recommendList = data.recommendList;
           this.weekendList = data.weekendList;
           console.log("请求服务器数据成功");
         }
     }

  },
  mounted () {
    this.getHomeInfo()
  }
}
</script>

<style scoped>

</style>
